<template>
  <div>
    <el-container class="home_container">
  <el-header>
    <div>
        <img src="../../assets/logo.5b13fac4.png" alt="" />
        
      </div>
    <el-button type="info" @click="loginout">退出</el-button>
  </el-header>
  <el-container>
    <!-- 侧边栏 -->
    <el-aside :width="ishow ? '64px' : '200px'">
      <div class="ttt" @click="ttt" >|||</div>
      <el-menu unique-opened 
      background-color="#333744"
          text-color="#fff"
      :collapse="ishow"
      :collapse-transition="false"
      router
      :default-active="index"
      
      >
      <el-menu-item index="/welcome">
        <i class="el-icon-headset"></i>
        <span slot="title">Music</span>
      </el-menu-item>
      <!-- 一级菜单 -->
      <el-submenu :index="x.id +''"  v-for="(x) in muenlist" :key="x.id">
        <!-- 一级菜单模板区 -->
        <template slot="title">
          <i :class="iconsObj[x.id]"></i>
          <span>{{ x.authName }}</span>
        </template>
        <!-- 二级菜单 -->
        <el-menu-item
              :index="'/' + y.path + ''"
              v-for="y in x.children"
              :key="y.id" 
              @click="getindex('/' + y.path)"
            >
              <i class="el-icon-menu"></i>
              <span>{{ y.authName }}</span>
            </el-menu-item>
       
      </el-submenu>
      
    </el-menu>
    </el-aside>
    <el-main>
      <router-view></router-view>
    </el-main>
  </el-container>
</el-container>
  </div>
</template>

<script>

import { getmenus } from '@/api/user'
import {delToken} from '../../utils/storage'
export default {
  data() {
    return {
      iconsObj: {
        125: 'iconfont icon-user',
        103: 'iconfont icon-tijikongjian',
        101: 'iconfont icon-shangpin',
        102: 'iconfont icon-danju',
        145: 'iconfont icon-baobiao',
      },
      muenlist: [],
      ishow: false,
      index:''
    }
  },
 async created() {
  let res = await getmenus()
  this.muenlist = res.data
  },
  methods: {
    getindex(index) {
      window.sessionStorage.setItem('index',index)
      this.index = index
    },
    ttt() {
      this.ishow = !this.ishow
    },
    loginout() {
      delToken()
      this.$store.commit('user/delToken')
      this.$router.push('/login')
    }
}
}
</script>

<style lang="less" scoped>
.el-container {
  height: 100vh;
}
.el-header {
  display: flex;
  justify-content: space-between;
  padding-left: 0;
  background-color: #373d41;
  color: #fff;
  font-size: 25px;
}
.el-aside{
  height: 100%;
  width: 200px;
  background-color: #373d41;
  .el-menu {
    border-right: none;
  }
 
}
.el-main {
  background-color: #e9edf1;
 
}
img {
  height: 100%;
}
.welcome-text{
  font-family: magicFont;
  font-size: 50px;
  margin: 0;
  display: block;
    margin-block-start: 1em;
    margin-block-end: 1em;
    margin-inline-start: 0px;
    margin-inline-end: 0px
}
.welcome{
  text-align: center;
}
.iconfont {
  margin-right:15px;
}
.ttt {
  text-align: center;
  color: #fff;
}
</style>